import request from '@/utils/request'

const gsCaApi = '/goodsCategory'

export function pageGc(params) {
  return request({
    url: `${gsCaApi}/page`,
    method: 'get',
    params: params
  })
}

export function getGcTree(params) {
  return request({
    url: `${gsCaApi}/trees`,
    method: 'get',
    params: params
  })
}

export function addGc(obj) {
  return request({
    url: `${gsCaApi}`,
    method: 'post',
    data: obj
  })
}

export function getGcById(id) {
  return request({
    url: `${gsCaApi}/` + id,
    method: 'get'
  })
}

export function delGc(id) {
  return request({
    url: `${gsCaApi}/` + id,
    method: 'delete'
  })
}

export function updateGc(obj) {
  return request({
    url: `${gsCaApi}`,
    method: 'put',
    data: obj
  })
}

/**
 * 更改商品分类状态
 * @param id
 * @param status
 * @returns {AxiosPromise}
 */
export const changeGcStatus = (id, status) => {
  let data = {
    id,
    status
  }
  return request({
    url: `${gsCaApi}/changeStatus`,
    method: 'PUT',
    data
  })
}
